package cn.biplam.front.component.view.systemManage.sysprivi.privilege.menu.navi;

import cn.biplam.common.ajxcode.SystemCode.MenuCode;
import cn.biplam.common.ajxcode.SystemCode.MenuNaviCode;
import cn.biplam.common.ajxcode.SystemCode.TreeDcIndexCode;
import cn.biplam.common.struc.SysStruc.PriviStruc;
import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.common.wrapper.UserInfo;
import cn.biplam.front.component.data.tree.treebase.TreeCallBackImg;
import cn.biplam.front.component.data.tree.treebase.TreeCallBackNew;
import cn.biplam.front.component.data.tree.treebase.TreeDcIndex;
import cn.biplam.front.component.data.tree.treebase.Tree_Type.Tree_NodeType_Commen;
import cn.biplam.front.component.data.tree.treebase.Tree_Type.Tree_PicType;
import cn.biplam.front.component.view.tree.TreeBase;
import cn.biplam.front.component.view.tree.TreeView;

/**
 *  菜单管理导航栏
 * @author XiaoRuxing Dec 8, 20099:26:25 AM
 * @version 1.0
 */
public class MenuNavi extends TreeView{

	public final static String cId=MenuNaviCode.cId;
	/** 树展开动作ID */
	public static final String Expand = MenuNaviCode.Navi;

	private static String nodeId;
	private static final String actionNodePic = "";

	public MenuNavi() {
		super(Expand);
	}

	/**
	 * 传入树节点链接到的目标容器ID初始化
	 * @param targetId
	 */
	public void setTarget(String targetId) {
		this.targetId=targetId;
	}

	/**
	 *  设置根节点ID
	 * @param rootID 根节点ID
	 */
	public void setRootId(String rootID){
		nodeId = rootID;
	}

	/**
	 * 设置树的数据信息
	 * @param treeBase			树的基础VC
	 * @param mUser				页面请求的用户类(由调用树的vc传入)
	 * @throws ErrorMessage
	 */
	@Override
	protected void setTree(TreeBase treeBase, UserInfo mUser)
	throws ErrorMessage {
		/**树的callback设置*/
		TreeCallBackNew callback = new TreeCallBackNew();
		//设置用户左键事件链接到显示用户信息
		callback.putLeftClick(Tree_NodeType_Commen.SubTheme, MenuCode.Menu_Info, this.targetId);
		callback.putLeftClick(Tree_NodeType_Commen.Leaf, MenuCode.Menu_Info, this.targetId);
		//设置树DC
		treeBase.putTreeDc(1, 
				new TreeDcIndex(mUser,//用户信息
						PriviStruc.Table_Name,   //用户索引表名
						null,
						nodeId,
						"2"),
				callback);

		//在根节点上设置右键
		treeBase.putRightMenuItem(1, Tree_NodeType_Commen.RootTheme, MenuCode.Add_Menu, "创建一级菜单");
		//设置一级菜单右键
		treeBase.putRightMenuItem(1, Tree_NodeType_Commen.SubTheme,  MenuCode.Add_Menu, "创建二级菜单");
		treeBase.putRightMenuItem(1, Tree_NodeType_Commen.SubTheme,  MenuCode.Edit_Menu, 		"修改");
		treeBase.putRightMenuItem(1, Tree_NodeType_Commen.SubTheme,  MenuCode.Del_Menu, 		"删除");
		//设置二级菜单节点右键
		treeBase.putRightMenuItem(1, Tree_NodeType_Commen.Leaf,  TreeDcIndexCode.Add_Leaf, "创建三级菜单");
		treeBase.putRightMenuItem(1, Tree_NodeType_Commen.Leaf, TreeDcIndexCode.Add_Leaf, "创建操作");
		treeBase.putRightMenuItem(1, Tree_NodeType_Commen.Leaf, MenuCode.Edit_Menu, "修改");
		treeBase.putRightMenuItem(1, Tree_NodeType_Commen.Leaf, MenuCode.Del_Menu, "删除" );
		//设置三级菜单右键
		treeBase.putRightMenuItem(1, Tree_NodeType_Commen.Custom, TreeDcIndexCode.Add_Leaf, "创建操作");
		treeBase.putRightMenuItem(1, Tree_NodeType_Commen.Custom, TreeDcIndexCode.Add_Leaf, "删除");
		//设置操作节点右键
		treeBase.putRightMenuItem(1, Tree_NodeType_Commen.Custom, TreeDcIndexCode.Add_Leaf, "创建操作", "2");
		treeBase.putRightMenuItem(1, Tree_NodeType_Commen.Custom, TreeDcIndexCode.Add_Leaf, "删除", "2");
		//设置操作节点图片
		TreeCallBackImg img = TreeCallBackImg.getInstanct(Tree_PicType.Blue);
		img.setCustomer(actionNodePic, Tree_NodeType_Commen.Custom.toString(), "2");
		treeBase.setPic(1, img);
	}
}
